<template>
  <div style="margin-top:2px;">
    <label class="app-container"> 清单选择：</label>
    <el-select v-model="selectTypeValue" placeholder="请选择清单" size="mini" @change="fnEdit">
      <el-option
        v-for="item in transoPtions()"
        :key="item.value"
        :label="item.label"
        :value="item.value"
      >
        <!-- <span style="float: left;">{{ item.label }}</span>
        <el-tooltip placement="top">
          <div slot="content">{{ item.address }}</div>
          <el-button @click="">document.querySelector(id).scrollIntoView(true)</el-button>
        </el-tooltip> -->
      </el-option>
    </el-select>
    <!-- <span>路径：{{ plugsPath }} </span> -->
    <bpmsPlu v-if="selectTypeValue === 'bpmsPlu' " ref="bpmsPlu" />
    <traitStore v-if="selectTypeValue === 'traitStore' " ref="traitStore" />
    <brandId v-if="selectTypeValue === 'brandId' " ref="brandId" />
    <pbBrandId v-if="selectTypeValue === 'pbBrandId' " ref="pbBrandId" />
    <countryAndCity v-if="selectTypeValue === 'countryAndCity' " ref="countryAndCity" />
    <ipName v-if="selectTypeValue === 'ipName' " ref="ipName" />
    <countryOfOrigin v-if="selectTypeValue === 'countryOfOrigin' " ref="countryOfOrigin" />
    <specialFinelineList v-if="selectTypeValue === 'specialFinelineList' " ref="specialFinelineList" />
    <hostVnmt v-if="selectTypeValue === 'hostVnmt' " ref="hostVnmt" />
    <freshFoodPiFineline v-if="selectTypeValue === 'freshFoodPiFineline' " ref="freshFoodPiFineline" />
  </div>
</template>

<script>
import bpmsPlu from '@/views/system-manage/plugs/bpmsPlu/list'
import traitStore from '@/views/system-manage/plugs/traitStore/list'
import brandId from '@/views/system-manage/plugs/brandId/list'
import pbBrandId from '@/views/system-manage/plugs/pbBrandId/list'
import countryAndCity from '@/views/system-manage/plugs/countryAndCity/list'
import ipName from '@/views/system-manage/plugs/ipName/list'
import countryOfOrigin from '@/views/system-manage/plugs/countryOfOrigin/list'
import specialFinelineList from '@/views/system-manage/plugs/specialFinelineList/list'
import hostVnmt from '@/views/system-manage/plugs/hostVnmt/list'
import freshFoodPiFineline from '@/views/system-manage/plugs/freshFoodPiFineline/list'
export default {
  components: { bpmsPlu, traitStore, brandId, pbBrandId, countryAndCity, ipName, countryOfOrigin, specialFinelineList, hostVnmt, freshFoodPiFineline },
  data() {
    return {
      disabled: false,
      plugsPath: '',
      options: [{ value: 'bpmsPlu', label: '1-BPMS-PLU', address: '\\cnnts8005fs\\Public\\Logistics\\Sys_ItemProject\\BPMS_PLU.xlsx' }, // 以下这些的路径只作显示跳转要做处理
        { value: 'traitStore', label: '2-LOCAL-COD-TS-NEW', address: '\\cnnts8005fs\\Public\\Logistics\\Sys_ItemProject\\Trait_Store.xlsx' },
        { value: 'brandId', label: '3-BRAND-ID', address: '\\cnnts8005fs\Public\Logistics\PLU List\BrandID.xlsm' },
        { value: 'pbBrandId', label: '4-PB-BRAND-ID', address: '\\cnnts8005fs\Public\Logistics\PLU List\BrandID.xlsm' },
        { value: 'countryAndCity', label: '5-COUNTRY-AND-CITY', address: '\\cnnts8005fs\Private\SCMDSE\SCReport\Macro\OIF Templet\请使用此New Item表格提交文件！\City_Country.xlsx' },
        { value: 'ipName', label: '6-IP-NAME', address: '\\cnnts8005fs\Private\SCMDSE\SCReport\Macro\OIF Templet\请使用此New Item表格提交文件！\IP_Name.xlsx' },
        { value: 'countryOfOrigin', label: '7-COUNTRY-OF-ORIGIN', address: '\\cnnts8005fs\Public\Logistics\Sys_ItemProject\COUNTRY_OF_ORIGIN.xlsx' },
        { value: 'specialFinelineList', label: '8-SPECIAL-FINELINE-LIST' },
        { value: 'hostVnmt', label: '9-Host-Vnmt' },
        { value: 'freshFoodPiFineline', label: '10-FreshFood-PiFineline' }
      ],
      plugsPathList: [{ label: 'bpmsPlu', value: '\\\\cnnts8005fs\\Public\\Logistics\\Sys_ItemProject\\BPMS_PLU.xlsx' }, // 以下这些的路径只作显示跳转要做处理
        { label: 'traitStore', value: '\\\\cnnts8005fs\\Public\\Logistics\\Sys_ItemProject\\Trait_Store.xlsx' },
        { label: 'brandId', value: '\\\\cnnts8005fs\\Public\\Logistics\\PLU List\\BrandID.xlsm' },
        { label: 'pbBrandId', value: '\\\\cnnts8005fs\\Public\\Logistics\PLU List\\BrandID.xlsm' },
        { label: 'countryAndCity', value: '\\\\cnnts8005fs\\Private\\SCMDSE\\SCReport\Macro\OIF Templet\\请使用此New Item表格提交文件！\\City_Country.xlsx' },
        { label: 'ipName', value: '\\\\cnnts8005fs\\Private\\SCMDSE\SCReport\Macro\\OIF Templet\\请使用此New Item表格提交文件！\\IP_Name.xlsx' },
        { label: 'countryOfOrigin', value: '\\\\cnnts8005fs\\Public\\Logistics\\Sys_ItemProject\\COUNTRY_OF_ORIGIN.xlsx' },
        { label: 'bpmsPlu4', value: '龙须面' },
        { label: 'bpmsPlu5', value: '北京烤鸭' }
      ],
      value: '',
      selectTypeValue: ''
    }
  },
  created() {
    this.selectTypeValue = this.transoPtions()[0].value
    this.plugsPath = this.transoPtions()[0].value
  },
  methods: {
    transoPtions() {
      const role = this.hasRole(['R017013'])
      const role2 = this.hasRole(['R017001'])
      return (role && !role2) ? this.options.filter((item) => item.value === 'freshFoodPiFineline') : this.options
    },
    fnEdit(vId) {
      for (const pathIndex in this.plugsPathList) {
        var path = this.plugsPathList[pathIndex]
        if (path && path.label === vId) {
          this.plugsPath = path.value
        }
      }
    }
  }
}
</script>
